﻿
namespace GalFrameWork.Utils;
public class ImageUtil {
    public async Task<ImageSource> ChangeFileToImage(FileResult result)
    {
        if (result != null)
            {
                if (result.FileName.EndsWith("jpg", StringComparison.OrdinalIgnoreCase) ||
                    result.FileName.EndsWith("png", StringComparison.OrdinalIgnoreCase))
                {
                    using var stream = await result.OpenReadAsync();
                    var image = ImageSource.FromStream(() => stream);
                return image;
                }
            }
            return null;
    }
    
}

